
##################################################################

class fm_command(object):

    def __init__(self):
        self.__myStr=''
        self.__myTerm='\r'
        
    def on_msgArrival(self,iStr):
        self.__myStr += iStr
        pos = self.__myStr.find(self.__myTerm)   
        while (pos >=0):
            on_Command(self.__myStr[0:pos])
            self.__myStr=self.__myStr[pos+1:len(self.__myStr)]
            pos =  self.__myStr.find(self.__myTerm)

##################################################################

def on_Command(cmd):
    if len(cmd)>0 :
        print (":" + cmd)

d = fm_command()
d.on_msgArrival('Hello\r123\r')
d.on_msgArrival('\rAABB\rccdd\r')
#d.findCmd()


